package com.xxx.demo.client.command;

import com.github.butid.data.base.BaseCommand;
import com.github.butid.data.codec.RequestBody;
import com.github.butid.data.codec.ResultBody;
import com.github.butid.data.netty.annotation.CommandController;
import com.xxx.demo.client.entity.Demo;
import com.xxx.demo.client.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created By wangjing.dc@qq.com On 2019-12-07
 **/
@Slf4j
@CommandController(cmdType = "STAT", cmdCode = "trans")
public class DemoCommand extends BaseCommand {

    @Autowired
    private DemoService demoService;

    @Override
    public ResultBody exec(RequestBody messageBean) {
        log.info("收到STAT --> {}", messageBean);

        List<Demo> all = demoService.list();
        log.info("查询结果:{}", all);

        return this.success(all);
    }
}
